feat(autonomy): carry decision policies on the semi mode commands (#2253 Bolt semi-policy-carrier) - #2316
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthrough半自律ポリシーを保存・正規化し、スコープ付き権限でゲート、質問、エフェクトを判定します。非フルモードの確認ダイジェストとCLI制約を更新し、ポリシー数を投影状態から表示します。単体・統合テストで保存、監査リプレイ、拒否、状態表示を検証します。 ChangesIntent 自律性
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/framework/core/hooks/amadeus-statusline.ts`:
- Line 334: Update the Completed/Complete status branch in the status-line
rendering flow to pass its output through withAutonomySegment before calling
printLine, matching the existing behavior at the later printLine call. Preserve
the branch’s current completion output and early return while ensuring valid
Intent Autonomy Mode values render `@semi`, `@full`, or `@none`.
In `@packages/framework/core/tools/amadeus-intent-autonomy-production.ts`:
- Around line 487-488:
「Scope」の解決ロジックがgrantScopeと半自律処理で重複しているため、getField(input.stateContent, "Scope")
??
"intent"を小さな共有ヘルパへ抽出してください。grantScopeと487行付近のscopeId生成の両方でそのヘルパを使用し、既定値が常に一致するようにしてください。
- Around line 296-305:
半自律経路のスコープ識別子が状態由来の値になり、確認済みポリシーの照合に失敗しています。semiPoliciesAfter
が保存する値と一致するよう、semiAuthorityScope および commitProductionStageGateDecision
から半自律認可へ渡すスコープを SEMI_POLICY_SCOPE_ID に統一し、状態の Scope は grant 用の処理にのみ使用してください。
In `@packages/framework/core/tools/amadeus-intent-autonomy.ts`:
- Around line 602-635: Update SemiAuthority.fingerprint and its call in
SemiAuthority.of to incorporate the complete SemiAuthorityScope, including
allowedInteractionKinds, into the authority digest rather than only
scopeFingerprint. Preserve the existing mode provenance and policy inputs so
distinct scope permissions produce distinct authorityFingerprint and downstream
basisFingerprint values.
- Around line 363-371: Update the decision-side semiAuthorityScope handling in
commitProductionStageGateDecision to use SEMI_POLICY_SCOPE_ID instead of the
state Scope value, ensuring it matches the "intent" fingerprint used when
storing semi policies. Add a test that detects mismatched Scope values and
verifies the stored semi policy remains eligible for resolveConfirmedPolicy.
In `@tests/integration/t450-autonomy-flag-branch.test.ts`:
- Around line 126-133: Update the test around the “the freeform intent text
survives the flag” case so its assertions verify the behavior named by the test:
seed the required state and positively assert that the downstream directive
preserves the intended text, or rename the test to describe only that “semi” is
not interpreted as intent content and align the assertions with that narrower
behavior.
In `@tests/unit/t452-authorize-interaction-semi.test.ts`:
- Around line 241-249: Remove the source-inspection test named “the ladder entry
names no autonomy mode” from tests/unit/t452-authorize-interaction-semi.test.ts;
the existing authorization-required behavior test already covers the intended
resolveAutoDecision behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d9a7578b-9f29-48ea-89c1-63103a2f4b50
📒 Files selected for processing (23)
packages/framework/core/hooks/amadeus-statusline.tspackages/framework/core/tools/amadeus-bolt.tspackages/framework/core/tools/amadeus-intent-autonomy-production.tspackages/framework/core/tools/amadeus-intent-autonomy-runtime.tspackages/framework/core/tools/amadeus-intent-autonomy.tspackages/framework/core/tools/amadeus-lib.tspackages/framework/core/tools/amadeus-orchestrate.tspackages/framework/core/tools/amadeus-utility.tstests/.coverage-patch-allowlist.jsontests/.coverage-ratchet.jsontests/.coverage-registry.jsontests/integration/t-coverage-mechanism-ratchet.test.tstests/integration/t432-intent-autonomy-runtime.integration.test.tstests/integration/t450-autonomy-flag-branch.test.tstests/integration/t453-semi-ladder-runtime.integration.test.tstests/integration/t455-semi-policy-cli.integration.test.tstests/unit/t431-intent-autonomy.test.tstests/unit/t448-autonomy-statusline-segment.test.tstests/unit/t449-autonomy-flag-parse.test.tstests/unit/t450-autonomy-flag-apply.test.tstests/unit/t451-semi-authority.test.tstests/unit/t452-authorize-interaction-semi.test.tstests/unit/t454-semi-policy-carrier.test.ts
| if (agentDisplay) output += ` -- ${agentDisplay}`; | ||
|
|
||
| printLine(output, right); | ||
| printLine(withAutonomySegment(output, state), right); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
完了状態にも自律性セグメントを適用してください。
status === "Completed" || status === "Complete" の分岐は、Line 324 で直接 printLine を呼び、Line 334 より前に return します。
そのため、有効な Intent Autonomy Mode を持つ完了済み Intent は @semi、@full、または @none を表示しません。完了時の出力も withAutonomySegment を通してください。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/framework/core/hooks/amadeus-statusline.ts` at line 334, Update the
Completed/Complete status branch in the status-line rendering flow to pass its
output through withAutonomySegment before calling printLine, matching the
existing behavior at the later printLine call. Preserve the branch’s current
completion output and early return while ensuring valid Intent Autonomy Mode
values render `@semi`, `@full`, or `@none`.
| test("the freeform intent text survives the flag", () => { | ||
| proj = createTestProject(); | ||
| const { directive } = runNextInProcess(proj, ["--autonomy", "semi", "build", "the", "auth", "service"]); | ||
| // Judgment 0 (no state) refuses, but the parse that got here consumed the | ||
| // mode: nothing downstream ever sees "semi" as intent words. | ||
| expect(directive.kind).toBe("error"); | ||
| expect(String(directive.message)).not.toContain("semi build"); | ||
| }); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
このテストはテスト名の性質を検証していません。
テスト名は「freeform intent text がフラグを越えて生存する」と述べます。しかし状態ファイルが存在しないため、handleNext は Judgment 0 で error を返します。intent text の行き先は観測できません。残るのは not.toContain("semi build") という否定アサーションだけで、これは message に "semi" が単独で含まれても通ります。
状態ファイルを seed して intent text が下流に到達することを肯定的に検証するか、テスト名を実際の性質(モードが intent 語として解釈されないこと)に合わせてください。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/integration/t450-autonomy-flag-branch.test.ts` around lines 126 - 133,
Update the test around the “the freeform intent text survives the flag” case so
its assertions verify the behavior named by the test: seed the required state
and positively assert that the downstream directive preserves the intended text,
or rename the test to describe only that “semi” is not interpreted as intent
content and align the assertions with that narrower behavior.
| test("the ladder entry names no autonomy mode", () => { | ||
| const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts"); | ||
| return source.text().then((text) => { | ||
| const body = text.slice(text.indexOf("export function resolveAutoDecision(")); | ||
| const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization")); | ||
| expect(functionBody).not.toContain('mode !== "full"'); | ||
| expect(functionBody).toContain('reason: "authorization-required"'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
ソース文字列を読むメタテストは脆弱です。削除を推奨します。
問題は3点です。
Bun.fileに相対パスを渡すため、テストの CWD がリポジトリルート以外だと失敗します。body.indexOf("\nexport type EffectAuthorization")が該当シンボルを見つけられない場合、戻り値は-1です。slice(0, -1)は末尾1文字だけを落とすため、functionBodyがファイルのほぼ全体になります。アサーションは無言で緩みます。- 実装のリファクタで容易に壊れます。
resolveAutoDecision が自律モードを見ないという性質は、220-225行の authorization-required テストが既に振る舞いとして検証しています。このテストは不要です。
♻️ 削除案
- test("the ladder entry names no autonomy mode", () => {
- const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts");
- return source.text().then((text) => {
- const body = text.slice(text.indexOf("export function resolveAutoDecision("));
- const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization"));
- expect(functionBody).not.toContain('mode !== "full"');
- expect(functionBody).toContain('reason: "authorization-required"');
- });
- });📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test("the ladder entry names no autonomy mode", () => { | |
| const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts"); | |
| return source.text().then((text) => { | |
| const body = text.slice(text.indexOf("export function resolveAutoDecision(")); | |
| const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization")); | |
| expect(functionBody).not.toContain('mode !== "full"'); | |
| expect(functionBody).toContain('reason: "authorization-required"'); | |
| }); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/unit/t452-authorize-interaction-semi.test.ts` around lines 241 - 249,
Remove the source-inspection test named “the ladder entry names no autonomy
mode” from tests/unit/t452-authorize-interaction-semi.test.ts; the existing
authorization-required behavior test already covers the intended
resolveAutoDecision behavior.
a627277 to
7f8c458
Compare
The semi arms of HumanAutonomyCommand now take raw policy inputs and planHumanAutonomyCommand owns the single normalization call, seeded by the command occurrence. nonFullCommandDisplayDigest folds the policy set into one confirmation digest for both non-full previews, and a carried set has to match the digest the human confirmed. The --status Policies line reads a grant-independent count so a semi Intent no longer reports zero.
t454 covers the write-side table, the digest definition and the three confirmation branches; t455 drives the same path through the CLI, the audit replay and the status render. The existing autonomy suites gain the new required field on their set-mode commands and keep their assertions.
The new integration test spawns the bolt and utility CLIs, so it joins the none-to-cli reclassification set and the regenerated coverage registry.
The Policies line now reads the grant-independent count, which changes the function's source fingerprint. The waived range is unchanged at 13 lines.
…ution The guard body is only reachable through a CLI spawn, which Bun does not attribute to the parent report. Collapsing it onto the predicate line matches the sibling --mode guard and keeps the arm out of the patch population.
7f8c458 to
94bb0c7
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
… (#2372) Bring the workflow record for #2253 onto main: the build-and-test stage's seven artifacts, the construction phase-boundary check, the goal reconciliation items and receipt, the appended audit shard, and the terminal state. The registry row advances in-flight → complete. Implementation for this intent already landed in seven PRs (#2293, #2294, #2295, #2316, #2317, #2318, #2321); this commit carries the record only — no source or test changes. Evidence recorded in the artifacts (measured on the conductor clone, values transcribed from command output): - bash tests/run-tests.sh --ci: exit 0, RESULT: PASS (11,494 pass / 0 fail) - build / typecheck / lint / source-only:check / complexity-gate: exit 0 - declared sensors on the seven artifacts: FIRED 14 / PASSED 14 / FAILED 0 - requirement traceability: 33 of 33 ids trace into the construction tree - formal-model-check: NOT_DETECTED (correlated run, no counterexample) - goal reconciliation: goal-statement ACHIEVED over 14 digest-verified refs The audit shard is a pure append over main's copy (main's bytes verified as a byte-exact prefix); the registry keeps every other row untouched. Refs #2253
概要
Intent
260805-semi-redefine-autonomy-f(Issue #2253)の Construction Boltsemi-policy-carrier(swarm batch 2)。set-autonomy --mode semiが受理した decision policies を無音破棄せず搬送・永続化する。after.semiPoliciesへ載せる(withSemiPoliciesは不在時 delete 方式)。SEMI_POLICY_SCOPE_ID = "intent"を単一定数化nonFullCommandDisplayDigestの 1 定義化と digest 照合(Q1 裁定準拠)policyCountの表示投影積み上げ(stacked PR)
本 PR は batch 1 の 3 PR(#2293 / #2294 / #2295)のマージコミット(
2c0221d3fで 3 bolt ブランチを統合)を base に持つ。batch 1 の 3 PR が先にマージされるまで diff に batch 1 のコミットが含まれる。 マージ順: #2293/#2294/#2295 → 本 PR(着地後に再接地予定)。テスト
tests/unit/t454-semi-policy-carrier.test.ts(新規)tests/integration/t455-semi-policy-cli.integration.test.ts(新規、CLI 面)検証(builder 実測)
build 0(drift なし)/ typecheck 0 / lint 0 / complexity 0 / registry 0 / source-only 0 / full
bash tests/run-tests.sh --ciPASS(853 files)。refereeamadeus-swarm checkconverged / finalize(batch 3)converged。申告(レビュー観点)
SEMI_POLICY_SCOPE_ID = "intent"は実装時導出(FD に明示逐語なし)policies: []を既存 6 呼び出し面へ追加(シグネチャ伝播)既知の外部ブロッカー
「No silent drop (trusted base ratchet)」は main 側 reconcile の連続失敗(#2313)により本 PR と無関係に赤になる。#2313 解消待ち。
Refs #2253
Note
High Risk
Changes intent autonomy authorization, policy persistence, audit digests, and launch/orchestrate entry points—areas where mistakes could auto-approve workflow decisions or weaken provenance checks.
Overview
Semi mode now persists decision policies on the autonomy projection (
semiPolicies), with one normalization path andnonFullCommandDisplayDigestso human confirmation matches what gets stored.set-mode/revoke-fullcommands carry raw policy inputs; non-empty sets require a matching confirmed digest.amadeus-bolt set-autonomyrejects--policies-filewith--mode none.Semi authorization is reworked around
SemiAuthority(replacing the old semi-mode-gate shortcut): production supplies asemiScope,authorizeInteractionreturnssemi-authority, and routine stage-gates and questions can auto-decide under semi while milestones (walking skeleton, phase boundaries) stay human. The decision ladder uses a sharedDecisionAuthority;policyCountin status counts grant or semi policies.Launch-time
--autonomyis parsed inparseNextFlags/takeAutonomyFlagand applied viaapplyLaunchAutonomyDeclaration(fail-closed on unreadable projection, no silent grant revoke, no overwriting an already human-declared mode). The statusline appends@none|semi|fullfromautonomySegment(FR-DISP-1).Reviewed by Cursor Bugbot for commit a627277. Configure here.
Summary by CodeRabbit
noneモードでポリシーファイルを指定した場合、読み込み前にエラーを表示します。